package org.lex.app.sessions;

import java.awt.Component;

import javax.swing.AbstractButton;

public class ButtonSession extends AbstractSession {
	private static final String SELECTED = "selected";

	@Override
	public Session getComponentProperties(Component c) {
		boolean b = ((AbstractButton) c).isSelected();
		this.putProperty(SELECTED, Boolean.toString(b));
		return this;
	}

	@Override
	public void restoreComponent(Component c) {
		String str = this.getProperty(SELECTED);
		if (null == str || str.isEmpty())
			return;
		((AbstractButton) c).setSelected(Boolean.valueOf(str));
	}
}
